package com.lagou.blog.controller;

import com.lagou.blog.pojo.Article;
import com.lagou.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class ArticleController {

	@Autowired
	private ArticleService articleService;


	@RequestMapping("/getArticleList")
	public String getArticleList(Model model, Integer page, Integer size){
		Pageable pageable = PageRequest.of(page, size);
		Page<Article> articleList = articleService.selectArticleList(pageable);
		model.addAttribute("articles", articleList);
		return "client/index";
	}

}
